home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr53 / 124_01.zip / HACKERS.TEX < prev    next >
Text File  |  1993-06-01  |  10KB  |  218 lines

  1. \input a:scribe
  2. \f:8=ff12
  3. \def\FF{\f:8}
  4. \majorhead{The tex Hackers Guide}
  5.  
  6. \head{Introduction}
  7.  
  8. This document is a guide to those tex users who are, for some
  9. reason, dissatisfied with the way tex works. Since tex is a stage
  10. one program (pasted up by some hacker with more guts than brains,
  11. and it does what I want) it is to be expected that lots of people
  12. will be dissatisfied with the way tex works. Therefore, this
  13. document is a guide to adding things to tex allowing easy
  14. integration into the tex distribution, and pointier to things
  15. that I think need to be done.
  16.  
  17. The first section discusses extending the existing macro
  18. packages.  The second section discusses adding new macro
  19. packages, and how to document them with little pain. The final
  20. section discusses changes to the actual tex code.
  21.  
  22. Before going into how these things can be done, there are two
  23. things to point out. First, the tex package {\b is not in the
  24. public domain!} I still own all copyrights, etc. I will,
  25. however, allow redistribution of the package on three conditions:
  26. {\verse
  27. 1) My copyright notices stay where they are.
  28. 2) The source is distributed with the package.
  29. 3) Fixes and improvements eventually come back to me.
  30. }
  31.  
  32. Second, tex was written to satisfy me, and I am happy with it. It
  33. was designed to let me use the power of {\FF Fancy Font} on my
  34. math courses, and in writing letters.  It does an adequate job of
  35. that. It probably won't do an adequate job of anything that
  36. deviates too far from that.
  37.  
  38. \head{Changing the Macro Packages}
  39.  
  40. Probably the simplest thing in tex to change is the macro
  41. packages themselves. The general rule is: {\b DON'T.} The macro
  42. packages should be fairly complete. If you really want a large
  43. set of new commands, the thing to do is to add a new macro
  44. package that includes the commands you want. In this case, see
  45. the next section.
  46.  
  47. \subhead{New Characters}
  48.  
  49. There are two exceptions to the general rule of not changing
  50. macro packages. The first one is if you want to change the
  51. characters set around. For example, you may decide you need a new
  52. math mode character. Just print off a copy of the math fonts, and
  53. add it - probably to \example{math2,} as \example{math1} is about
  54. full. If you do this, send me a copy of the \example{edf} file
  55. for the character, and the command name you used on the
  56. character, and I'll see that the character/command pair winds up
  57. in the next distribution. Maybe not in the same place, but it
  58. will be there. I will also add that character to the
  59. documentation.
  60.  
  61. Along these lines, there are two things that I would like to see
  62. done, but don't have time to do. First, the Greek characters are
  63. a bit bolder than I would desire, and not quite to the right
  64. scale. This could be fixed.
  65.  
  66. Second, {\b all} the characters in the math2 font cause extra
  67. lines to be added to the output. I don't know why these lines are
  68. there, but it annoys me. If somebody (are you listening,
  69. SoftCraft?) would fix this, I would greatly appreciate it.
  70.  
  71. \subhead{Changing Tex}
  72.  
  73. The second reason to want to change a macro package is to take
  74. advantage of capabilities you have added to tex. There isn't much
  75. I can say about this, except that you ought to add the new
  76. commands to the documentation in the command list and the
  77. appendices. Or, when you send them to me, I can do it, and see
  78. that things get onto the tex distribution.
  79.  
  80. \head{Adding a New Macro Package}
  81.  
  82. If you don't like any of the macro packages currently available
  83. for tex, you'll probably want to add your own. If you are trying
  84. to make tex look like your favorite text formatter, I suggest
  85. that you consider carefully which commands should and shouldn't
  86. have arguments, based on the current 1K limit to argument sizes.
  87. For example, when the \example{scribe} package was added - to
  88. make tex behave like scribble - I made the \example{scribble}
  89. inline commands take arguments, and those that affect the
  90. environment were turned into simple commands.
  91.  
  92.  
  93. You should also document your new macro package in a manner
  94. similar to what is already there. The standard tex manual has
  95. been designed so that any macro package documentation can be put
  96. into it with very little work. Assume that your macro package is
  97. called \example{gort.} Then you need to create the file
  98. \example{mgort.tex} which documents the commands in the package.
  99. This file should look like \example{mbasic.tex.} Place it on the
  100. same disk as \example{mbasic.tex} (or whichever macro doc file
  101. you use), and modify the \example{macros} command in the file
  102. \example{texuman.tex} to use the name of the package in question.
  103. This should do the trick.
  104.  
  105. You should also build two versions of the macro package. One
  106. should include all the math mode commands, and use both math
  107. fonts. The other should only include the miscellaneous math mode
  108. commands, and not include the \example{math2} font. The reason for
  109. this is that there are {\b lots} of math mode commands, and for
  110. anything but mathematics, you won't need most of them. So the
  111. second version of the macro package doesn't include them, and
  112. also frees up another font file for the user. See the two basic
  113. macro package files, \example{sbasic.tex} and \example{basic.tex,} for
  114. examples.
  115.  
  116. I don't have any suggestions as to what kind of new macro
  117. packages need to be built. Naturally - I built the ones I want.
  118.  
  119. \head{Changing tex Itself}
  120.  
  121. Finally, we come to the part that every true hacker probably went
  122. to first. Well, it's not going to do them any good. I'm not going
  123. to talk about the details of tex's internals. Instead, I will talk
  124. about the major organization.
  125.  
  126. tex was designed to give me the ability to cleanly use the power
  127. of {\FF Fancy Font} as quickly as possible: I was in the middle
  128. of a very hairy algebra course when it was written, and wanted to
  129. get tex up without destroying my grades. I almost succeeded.
  130.  
  131. \subhead{The Insides of tex}
  132.  
  133. Given this constraint, it should come as no suprise that the
  134. basic algorithm that tex uses is stupid. To wit: tex reads in
  135. characters until it finds a word break, and then outputs the word
  136. and starts the next one with a space. If, at any time in this
  137. process, a character should be read in that wouldn't fit on the
  138. current line, tex starts a new line, and continues collecting
  139. words. To compound tex's stupidity, I let \example{pfont} do all the
  140. hard work: pagination, justification, etc. All tex does is word
  141. filling, macro expansion, and environment nesting. Fortunately,
  142. the result is very usable.
  143.  
  144. The last thing I have to say on the internals is that I tried
  145. hard (well, reasonably hard) to make it easy for other people to
  146. modify tex. Along these lines, all globals have nice, long names;
  147. procedures tend to have descriptive names (\examplg{docom, setleft,}
  148. etc), and every procedure is commented. Hopefully, you will have
  149. little trouble figuring out what is going on internally.
  150.  
  151. \subhead{tex Wish List}
  152.  
  153. There are only three things that I can think of that I would like
  154. to do to tex. I'm not going to do them - I'm going to play with
  155. my now two-month old LISP processor.
  156.  
  157. First, modify tex so that it inputs an entire line and does its
  158. own justification. This would allow the \example{rtmarg} command to be
  159. turned on, and a couple of commands for handling quotes, etc
  160. could be added to the \example{scribe} macro package.
  161.  
  162. Second, do the same thing as the first change, but vertically
  163. instead of horizontally: have tex do its own pagination. This
  164. would fix the \example{eject} kludge mentioned in the user manual,
  165. allow footers and headers to be done reasonably, and is necessary
  166. (but not sufficient) for adding footnotes to tex.
  167.  
  168. Finally, the major change. This is the change I was reserving for
  169. version 2. Go look at the source code: you will observe that
  170. the \example{processtext} function is the entry point for what amounts
  171. to a recursive descent parser for tex files. To facilitate macros
  172. and such things, the functions in this parser expect that one of
  173. their arguments is a function that will return the next character
  174. in the current input stream.
  175.  
  176. This parser needs to be changed so that its output can go
  177. somewhere other than the output file, by giving all the
  178. procedures a functional parameter that you pass characters to be
  179. output to. Such a change would allow such things as footnotes and
  180. endnotes. In addition, the input to the \example{ff} (or to the
  181. header/footer commands, if they exist by then) could be run
  182. through tex, so that you get to all the nice math mode characters.
  183.  
  184. \head{Last Note}
  185.  
  186. Well, so much for the things I think you should/can do to tex,
  187. and what to do if you do them. I would like to remind all the
  188. readers that if they are going to stay legal, they have to send
  189. me any changes they implement. The appropriate addresses are
  190. currently (Spring '83):
  191. {\verbatim
  192.  
  193. Post Offal: Mike Meyer
  194. P.O. Box 1749
  195. Norman, OK 73070
  196.  
  197. Ma Bell: 405/360-2508
  198.  
  199. ARPANet: mwm@okc-unix
  200.  
  201. UUCPNet: decvax!duke!uok!uokvax!mwm
  202.  
  203. CNet: Ishtar - the Oklahoma CNode 406/364-1373
  204. }
  205.  
  206. Obviously, I can't do a lot about it if you decide not to send me
  207. updates - unless you start distributing tex yourself. I probably
  208. won't get upset in that case, unless you are selling tex without my
  209. name on it. Then I may get legally angry.
  210.  
  211. In any case, I hope you get as much good out of tex as I am.
  212.  
  213. {\closing
  214. Happy hacking and may all your bugs be small,
  215.  
  216. Mike}
  217. header/footer commands, if they exist by then) could be run
  218. through tex, so th